<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<link href="${basePath }/css/timeline.css?v=2342" rel="stylesheet">
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
<style type="text/css">
li{list-style: none;}
.faile-infor{
	width:200px;
	float:left;
	font-size: 14px;
	color:#FC1515;
	padding:14px 0;
}

.row>div {
    margin-bottom: 0px;
}
</style>
</head>
<body class="gray-bg">
<div class="container creditbody">
	<div class="iboxtitle">
 		<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷后业务>贷后信息登记</span>
    </div>
    <div class="buttonfixed">
       <button type="button" class="btn dpbtn_blue btnaplly" onclick="save();">保存提交</button>
    </div>
	 <div class="ibox-content ibox-con">
		<%@include file="/jsp/common_yw_with_loan_include.jsp"%>
  		<%@include file="/jsp/loanAfterContent.jsp"%>	
  	</div>	
 	<form class="form-horizontal" id="commentForm">
  			<div class="business-man">贷后信息</div>
  			<div class="business-padding">	
  				<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
			<tr>
				<td align="right">
					<input id="loanAfterId" name="loanAfterId" value="${dhLoanAfter.id }" type="hidden" />
					<label class="control-label np">首月还款时间：</label>
				</td>
				<td>
					<input class="laydate-icon form-control" type="text" id="dateFirstMonth" name="dateFirstMonth" placeholder="首月还款时间" value="<fmt:formatDate value='${dhLoanAfter.dateFirstMonth }' pattern='yyyy-MM-dd'/>"/>
				</td>
				<td align="right">
					<label class="control-label np">还款日：</label>
				</td>
				<td>
					<input class="form-control" min="1" max="31" type="text" id="dateRepayment" name="dateRepayment" value="${dhLoanAfter.dateRepayment }" placeholder="还款日"/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label class="control-label np">对账单日：</label>
				</td>
				<td>
					<input class="form-control" type="text" max="29" min="1" id="bankStatementDate" name="bankStatementDate" value="${dhLoanAfter.bankStatementDate }" placeholder="对账单日"/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label class="control-label np">还款卡片寄送地址：</label>
				</td>
				<td colspan="3">
					<input  class="form-control" type="text" id="addrCardSend" name="addrCardSend" value="${dhLoanAfter.addrCardSend }" placeholder="还款卡片寄送地址"/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label class="control-label np">还款卡片寄出时间：</label>
				</td>
				<td>
					<input class="laydate-icon form-control" type="text" id="timeCardSend" name="timeCardSend" placeholder="还款卡片寄出时间" value="<fmt:formatDate value='${dhLoanAfter.timeCardSend }' pattern='yyyy-MM-dd'/>"/>
				</td>
				<td align="right">
					<label class="control-label np">还款卡片收到时间：</label>
				</td>
				<td>
					<input class="laydate-icon form-control" type="text" id="timeCardReceive" name="timeCardReceive" placeholder="还款卡片收到时间" value="<fmt:formatDate value='${dhLoanAfter.timeCardReceive }' pattern='yyyy-MM-dd'/>"/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label class="control-label np">快递运单号：</label>
				</td>
				<td>
					<input class="form-control" type="text" id="noExpress" name="noExpress" value="${dhLoanAfter.noExpress }" placeholder="快递运单号"/>
				</td>
				<td align="right">
					<label class="control-label np">寄送快递公司：</label>
				</td>
				<td>
					<mytag:selectTag id="companyExpress" name="companyExpress" map="${expressCompanyType }" selected="${dhLoanAfter.companyExpress }" others="class='select-control'"/>
				</td>
				<td valign="bottom">
					&nbsp;&nbsp;&nbsp;<button class="btn dpbtn_red" type="button" id="queryDeliver">执行查询</button>
				</td>
			</tr>
			</table>

			<div class="content content-posi hidden">
				<article id="expressDetail">
				</article>
			</div>
			
			<ul class="zxsearch-ulsd clear-both">
            	<li class="zxsearch-ulli">还款卡片寄送备注：</li>
            	<li class="zxsearch-ullib">
					<div class="bus-class_table">
                		<table cellpadding="0" cellspacing="0" border="0" bordercolor="#3B95C8"  width="100%">
                			<tr>
                				<td width="90%" align="left">
                					<div class="ibox-content no-padding">
                      		 			<div class="summernote2" id="remarkCardSend" name="remarkCardSend">${dhLoanAfter.remarkCardSend }</div>
                      				</div>
                				</td>
                			</tr>
                		</table>
               	   </div>
				</li>
		    </ul>
		</div>
		<!-- 当前经办人 -->
  		<%@include file="/jsp/comm_current_person_include.jsp"%>
	</form>
	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
 	<!-- summernote -->
 	<%@include file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>
 	
 	<!-- layerDate plugin javascript -->
    <script type="text/javascript" src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
	
	<!-- jqGrid -->
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>	
<!-- custom js -->
    
    <script type="text/javascript"></script>
    <!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
        var busiId;
        var queryCreditApplyId;
        
	    jQuery(function($) {  
	    	$('#remarkCardSend').summernote({
	            lang: 'zh-CN',
	            toolbar:[
					['style', ['bold', 'italic', 'underline', 'clear']],
					['color', ['color']]
	            ]
	        });
	    	//外部js调用
		    laydate({
		        elem: '#dateFirstMonth', 
		        event: 'focus' 
		    });
		    laydate({
		        elem: '#timeCardSend', 
		        event: 'focus' 
		    });
		    laydate({
		        elem: '#timeCardReceive', 
		        event: 'focus' 
		    });
		    
		    busiId = $('#busiId').val();
  		    queryCreditApplyId = $('#queryCreditApplyId').val();
		    
		    $('#queryDeliver').click(function() {
		    	queryDeliver(false);
		 	});
		    
		    queryDeliver(true);
	    });
	    
		//确认签署
		function save(){
			var data = {};
			data.id = $('#loanAfterId').val();
			data.busiId = $('#busiId').val();
			data.cusId = $('#customerId').val();
			data.dateFirstMonth = $('#dateFirstMonth').val();
			data.timeCardSend = $('#timeCardSend').val();
			data.timeCardReceive = $('#timeCardReceive').val();
			data.dateRepayment = $('#dateRepayment').val();
			data.addrCardSend = $('#addrCardSend').val();
			data.noExpress = $('#noExpress').val();
			data.bankStatementDate = $('#bankStatementDate').val();
			data.companyExpress = $('#companyExpress').val();
			data.remarkCardSend = $('#remarkCardSend').code();
			var validstatus = $("#commentForm").valid();
	    	if(!validstatus) {	    	
	    		layer.msg("有验证未通过，请仔细检查！", {icon: 5});
	    		return;
	    	}	
			$.dpAjax({
 	    		url:'${basePath}/DhLoanAfterController/loanAfter',
 	    		data:data,
     			success: function(datas){
	     			  if(datas.flag == "100100")
 					  {
	     				 $('#loanAfterId').val(datas.result);
	     				 layer.msg('贷后信息登记成功', {icon: 6,time:3000});
 						 return;
 					  }
 					  if(datas.flag == "100200")
 	                  {
 						  $.fn.showDatas({"datas":datas});
 	                	  return;
 	                  }
 					  layer.msg(datas.message, {icon: 2});
                 }
 	    	});
		}
		//查询快递
		function queryDeliver(first){
			var nu = $('#noExpress').val();
			if(!nu || nu == ''){
				if(!first) {
					layer.msg('请输入快递运单号', {icon: 5});
				}
				return;
			}
			var data = {};
			data.nu = nu;
			var com = $('#companyExpress').val();
			if(com && com != ''){
				data.com = com;
			}
	    	$.dpAjax({
	    		show:true,
		    	url:'${basePath}/DhLoanAfterController/queryExpress',
		    	data:data,
	 			success: function(datas){
	     			  if(datas.flag == "100100"){
	     				$('.content-posi').removeClass('hidden');
	     				var result = datas.result;
	     				var aliDeliverInfoDetails = result.aliDeliverInfoDetails;
	     				$('#expressDetail').empty();
	     				 var html = "";
	     				 if(aliDeliverInfoDetails && aliDeliverInfoDetails.length > 0) {
	     					 var length = aliDeliverInfoDetails.length;
	     					 
	     					for(var i = 0; i < length; i++) {
		     					 var aliDeliverInfoDetail = aliDeliverInfoDetails[i];
		     					 var classT = '';
		     					var classP = '';
		     					 if((i == length - 1) && (!result.success)) {
		     						classT = 'text-yellow';
		     						classP = 'point-yellow';
		     					 } else if((i == length - 1) && (result.success)) {
		     						classT = 'text-green';
		     						classP = 'point-green';
		     					 }
		     					html += '<section><span class="point-time ' + classP + '"></span><time datetime="'+aliDeliverInfoDetail.time +'">';
		     					html += '<span ' + (classT != '' ? 'class="'+classT+'"' : '') + '>' + aliDeliverInfoDetail.time+'&nbsp;&nbsp;&nbsp;<span>' 
		     					html += aliDeliverInfoDetail.week + '</span></time><aside><p class="things ' + classT + '">';
		     					html += aliDeliverInfoDetail.context + '</p></aside></section>';
	     					 }
	     				 } else {
	     					layer.msg('快递信息获取失败！', {icon: 2});
	     				 }
	     				$('#expressDetail').html(html);
	     				 layer.msg('查询快递信息成功', {icon: 6,time:3000});
						 return;
					   }
					  if(datas.flag == "100200"){
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
					  layer.msg(datas.message, {icon: 2});
	             }
	    	});
		}
		
		//程立勇修改验证
		$(function(){	
		        $("#commentForm").validate({
		            rules: {
		            	dateRepayment:{
		            	},
		            },
		            //重写showErrors
		            showErrors: function (errorMap, errorList) {
		                
		                $.each(errorList, function (i, v) {
		                    layer.tips(v.message, v.element, { time: 1500 });
		                    return false;
		                });  
		            },
		            /* 失去焦点时验证 */
		            onfocusout: function(element) { $(element).valid(); },
		            /*  键盘抬起不验证 */
		            onkeyup:false,
		        });
			});
    </script>
</body>
</html>
